<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/7 0007
 * Time: 8:59
 */

namespace app\portal\controller;

use cmf\controller\AdminBaseController;
use think\Db;
use app\admin\model\Menu;
use app\portal\service\PostService;
use app\portal\model\PortalCategoryModel;

class MessageController extends AdminBaseController
{
    public function _initialize()
    {
    }
    public function index(){
        $message = Db::name('z_message_index')->select();
        $this->assign('message',$message);

        return $this->fetch();
    }

    /**
     * 留言删除
     */
    public function delete()
    {
        $param = $this->request->param();

        if (isset($param['id'])) {
            $id           = $this->request->param('id', 0, 'intval');
            $ls = Db::name('z_message_index')->delete($id);
            if($ls == 0){
             $this->error("删除失败了",'',$id);
            }else{
                $this->success("删除成功！", '',$id);
            }
        }

        if (isset($param['ids'])) {
            $ids     = $this->request->param('ids/a');

            $ls = Db::name('z_message_index')->delete($ids);
            if($ls == 0){
                $this->error("删除失败了",'');
            }else{
                $this->success("删除成功！", '');
            }
            }
        }
    }
